package com.myidis.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myidis.entity.QuotaDataItem;
import com.myidis.servlet.QuotaDataItemServlet;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/dataItem")
@Api(tags = "数据项管理接口")
public class QuotaDataItemController {
	@Autowired
	private QuotaDataItemServlet itemServlet;

	@ResponseBody
	@RequestMapping("/list")
	@ApiOperation("获取所有数据项信息")
	public List<QuotaDataItem> list() {
		return itemServlet.all();
	}

	@ResponseBody
	@RequestMapping("/entity")
	@ApiOperation("获取一个数据项信息")
	public QuotaDataItem one(@RequestBody QuotaDataItem quotaDataItem) {
		return itemServlet.getOne(quotaDataItem.getId());
	}
	
	@ResponseBody
	@RequestMapping("/add")
	@ApiOperation("添加一个数据项信息")
	public int add(@RequestBody QuotaDataItem quotaDataItem) {
		return itemServlet.insert(quotaDataItem);
	}
	
	@ResponseBody
	@RequestMapping("/addAll")
	@ApiOperation("添加一组数据项信息")
	public int addAll(@RequestBody List<QuotaDataItem> quotaDataItems) {
		return itemServlet.insertAll(quotaDataItems);
	}

	@ResponseBody
	@RequestMapping("/upd")
	@ApiOperation("修改一个数据项信息")
	public int upd(@RequestBody QuotaDataItem quotaDataItem) {
		return itemServlet.update(quotaDataItem);
	}

	@ResponseBody
	@RequestMapping("/del")
	@ApiOperation("删除一个数据项信息")
	public int del(@RequestBody int id) {
		return itemServlet.delete(id);
	}
	
	@ResponseBody
	@RequestMapping("/delAll")
	@ApiOperation("删除一组数据项信息")
	public int delAll(@RequestBody int[] ids) {
		return itemServlet.deleteAll(ids);
	}
}
